package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/user")
public class ApUserController {

    @Autowired
    private ApUserService apUserService;

    @GetMapping("/{id}")
    public ResponseResult findById(@PathVariable Integer id) {
//        if (StringUtils.isBlank(id)){
//            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
//        }
//        return ResponseResult.okResult(apUserService.getById(id));
        ApUser apUser = apUserService.getById(id);
        return ResponseResult.okResult(apUser);
    }
}